# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Redis.V1.Model.CrossClusterReplicationConfig do
  @moduledoc """
  Cross cluster replication config.

  ## Attributes

  *   `clusterRole` (*type:* `String.t`, *default:* `nil`) - The role of the cluster in cross cluster replication.
  *   `membership` (*type:* `GoogleApi.Redis.V1.Model.Membership.t`, *default:* `nil`) - Output only. An output only view of all the member clusters participating in the cross cluster replication. This view will be provided by every member cluster irrespective of its cluster role(primary or secondary). A primary cluster can provide information about all the secondary clusters replicating from it. However, a secondary cluster only knows about the primary cluster from which it is replicating. However, for scenarios, where the primary cluster is unavailable(e.g. regional outage), a GetCluster request can be sent to any other member cluster and this field will list all the member clusters participating in cross cluster replication.
  *   `primaryCluster` (*type:* `GoogleApi.Redis.V1.Model.RemoteCluster.t`, *default:* `nil`) - Details of the primary cluster that is used as the replication source for this secondary cluster. This field is only set for a secondary cluster.
  *   `secondaryClusters` (*type:* `list(GoogleApi.Redis.V1.Model.RemoteCluster.t)`, *default:* `nil`) - List of secondary clusters that are replicating from this primary cluster. This field is only set for a primary cluster.
  *   `updateTime` (*type:* `DateTime.t`, *default:* `nil`) - Output only. The last time cross cluster replication config was updated.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :clusterRole => String.t() | nil,
          :membership => GoogleApi.Redis.V1.Model.Membership.t() | nil,
          :primaryCluster => GoogleApi.Redis.V1.Model.RemoteCluster.t() | nil,
          :secondaryClusters => list(GoogleApi.Redis.V1.Model.RemoteCluster.t()) | nil,
          :updateTime => DateTime.t() | nil
        }

  field(:clusterRole)
  field(:membership, as: GoogleApi.Redis.V1.Model.Membership)
  field(:primaryCluster, as: GoogleApi.Redis.V1.Model.RemoteCluster)
  field(:secondaryClusters, as: GoogleApi.Redis.V1.Model.RemoteCluster, type: :list)
  field(:updateTime, as: DateTime)
end

defimpl Poison.Decoder, for: GoogleApi.Redis.V1.Model.CrossClusterReplicationConfig do
  def decode(value, options) do
    GoogleApi.Redis.V1.Model.CrossClusterReplicationConfig.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Redis.V1.Model.CrossClusterReplicationConfig do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
